package com.yanjr.modules.cms.entity;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.yanjr.common.Constants;
import com.yanjr.common.persistence.DataEntity;
import com.yanjr.common.persistence.Annotation.Column;
import com.yanjr.common.persistence.Annotation.Database;
import com.yanjr.common.persistence.Annotation.Table;
import com.yanjr.common.utils.StringUtils;
import com.yanjr.modules.sys.utils.UserUtils;

/**
 * 站点Entity
 * @ClassName: Site 
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author yanjr  2016年5月25日 下午3:47:52
 */
@Database("jeesite")
@Table("cms_site")
@Component
public class Site extends DataEntity<Site> {
	private static final long serialVersionUID = 1820779528486557466L;
	
	@Column("id")
	private String id;
	@Column("name")
	private String name;	// 站点名称
	@Column("title")
	private String title;	// 站点标题
	@Column("logo")
	private String logo;	// 站点logo
	@Column("domain")
	private String domain;//站点域名
	@Column("description")
	private String description;// 描述，填写有助于搜索引擎优化
	@Column("keywords")
	private String keywords;// 关键字，填写有助于搜索引擎优化
	@Column("theme")
	private String theme;	// 主题
	@Column("copyright")
	private String copyright;// 版权信息
	@Column("custom_index_view")
	private String customIndexView;// 自定义首页视图文件
	@Column("create_by")
	private String createBy;
	@Column("create_date")
	private Date createDate;
	@Column("update_by")
	private String updateBy;
	@Column("update_date")
	private Date updateDate;
	@Column("remarks")
	private String remarks;
	@Column("del_flag")
	private String delFlag = Constants.DEL_FLAG_NORMAL;
	
	public Site() {
		super();
	}
	
	public Site(String id){
		this();
		this.id = id;
	}


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}

	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getKeywords() {
		return keywords;
	}

	public void setKeywords(String keywords) {
		this.keywords = keywords;
	}

	public String getTheme() {
		return theme;
	}

	public void setTheme(String theme) {
		this.theme = theme;
	}

	public String getCopyright() {
		return copyright;
	}

	public void setCopyright(String copyright) {
		this.copyright = copyright;
	}

	public String getCustomIndexView() {
		return customIndexView;
	}

	public void setCustomIndexView(String customIndexView) {
		this.customIndexView = customIndexView;
	}

	public String getCreateBy() {
		return createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(String updateBy) {
		this.updateBy = updateBy;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(String delFlag) {
		this.delFlag = delFlag;
	}

	/**
	 * 获取默认站点ID
	 */
	public static String defaultSiteId(){
		return "1";
	}
	
	/**
	 * 判断是否为默认（主站）站点
	 */
	public static boolean isDefault(String id){
		return id != null && id.equals(defaultSiteId());
	}
	
	/**
	 * 获取当前编辑的站点编号
	 */
	public static String getCurrentSiteId(){
		String siteId = (String)UserUtils.getCache("siteId");
		return StringUtils.isNotBlank(siteId)?siteId:defaultSiteId();
	}

    /**
   	 * 模板路径
   	 */
   	public static final String TPL_BASE = "/WEB-INF/views/modules/cms/front/themes";

    /**
   	 * 获得模板方案路径。如：/WEB-INF/views/modules/cms/front/themes/jeesite
   	 *
   	 * @return
   	 */
   	public String getSolutionPath() {
   		return TPL_BASE + "/" + getTheme();
   	}
	
}